<template>
  <div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: 'KForm',
  props:{
    model:{
      type:Object,
      required:true
    },
    rules:{
      type:Object,
      default:{}
    }
  },
  provide(){
    return {
      form:this
    }
  },
  methods:{
    validate(fn){
      console.log(this.$children)
     const excute= this.$children
      .filter(item=>{return item.prop})
      .map(item=>{item.validate()})

    Promise.all(excute).then(()=>{
      fn(true)
    }).catch(err=>{
      fn(false)
    })
    }
  }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
